package com.boot.main.controller;

import com.boot.main.entity.ScomShop;
import com.boot.main.service.IShopService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@Slf4j
@RestController
@RequestMapping("/v1/api")
@Api(tags = "店铺管理")
public class ShopController {
    @Resource
    private IShopService shopService;

    @RequestMapping(value="/shops", method = RequestMethod.GET)
    @ApiOperation(value="获取店铺列表")
    public Object getShops(@RequestParam("page") Integer page, @RequestParam("limit") Integer limit, @RequestParam("name") String name){
        return shopService.getShops(page, limit, name);
    }

    @RequestMapping(value="/shop", method = RequestMethod.POST)
    @ApiOperation(value="新增店铺")
    public Object saveShop(@RequestBody ScomShop shop){
        return shopService.saveShop(shop);
    }

    @RequestMapping(value="/shop/{id}", method = RequestMethod.PUT)
    @ApiOperation(value="修改店铺")
    public Object updateShop(@RequestBody ScomShop shop){
        return shopService.updateShop(shop);
    }

    @RequestMapping(value="/shop/{id}", method = RequestMethod.DELETE)
    @ApiOperation(value="删除店铺")
    public Object deleteShop(@PathVariable Long id){
        return shopService.deleteShop(id);
    }
}
